<?php
/**
 * User: b179a9
 * Date: 10/12/11
 * Time: 4:22 PM
 */

class App_Form_User_Personal extends Zend_Form
{

    public function init()
    {

        $this->setAction('/user/personal');
        $this->setMethod('post');

        $postal = new Zend_Form_Element_Text('postal');
        $postal->setLabel('Postal code:')
            ->setRequired();
        $this->addElement($postal);

        $birthday = new Zend_Form_Element_Text('birthday');
        $birthday->setRequired()
            ->setLabel('Birthday date:')
            ->addValidator(new Zend_Validate_Date());
        $this->addElement($birthday);

        $firstName = new Zend_Form_Element_Text('name');
        $firstName->setRequired()
            ->setLabel('First name:')
            ->addFilter(new Zend_Filter_StripTags());
        $this->addElement($firstName);

        $lastName = new Zend_Form_Element_Text('lastName');
        $lastName->setRequired()
            ->setLabel('Last name:')
            ->addFilter(new Zend_Filter_StripTags());
        $this->addElement($lastName);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Save');
        $this->addElement($submit);

    }

    public function populate($values) {
        $values['gender'] = $values['gender']['id'];
        $values['birthday'] = $values['birthday']->format('Y-m-d');
        parent::populate($values);
    }

}
